package com.auth.web.spring;


import java.util.Iterator;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.auth.domain.T_user_function;
import com.auth.domain.T_user_role;
import com.auth.service.T_user_functionService;
import com.auth.service.T_user_roleService;
import com.common.utils.DateUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.auth.domain.T_user;
import com.auth.service.T_userService;
import com.common.db.JsonVO;
import com.common.db.Pg;
import com.common.utils.BeanUtils;

@Controller
@RequestMapping("/t_user")

public class T_userController
{
	private static Logger log = Logger.getLogger(T_userController.class.getName());

	@Resource
    private T_userService service;
	@Resource
	private T_user_roleService t_user_roleService;
	@Resource
	private T_user_functionService t_user_functionService;

	private Pg pg;

	/**
	 * 1、获取 T_user信息列表，并且在列表页面展示
	 * @param request
	 * @return Pg，json格式
	 */
	@RequestMapping("/getAllT_user")
	@ResponseBody
	public Pg getAllT_user(HttpServletRequest request){
		int pageSize = 10;
		int startIndex = 0;
		T_user t_user = new T_user();
		try{
			if(request.getParameter("pageSize")!=null){
				pageSize = BeanUtils.stringToInt("pageSizeFlag", request.getParameter("pageSize"));
			}
			if(request.getParameter("startIndex")!=null){
				startIndex = BeanUtils.stringToInt("startIndexFlag", request.getParameter("startIndex"));
			}
			if(request.getParameter("process_code")!=null){ //鍙栧緱鍔ㄤ綔娴� 娴佺▼鑻辨枃鍚嶇О锛屽悗鍙版煡璇㈡暟鎹叧鑱斾娇鐢�
				t_user.setProcess_code(request.getParameter("process_code"));
			}
			if(request.getParameter("userid")!=null&&!"".equals(request.getParameter("userid"))){
				t_user.setUserid(request.getParameter("userid"));
			}
			if(request.getParameter("password")!=null&&!"".equals(request.getParameter("password"))){
				t_user.setPassword(request.getParameter("password"));
			}
			if(request.getParameter("username")!=null&&!"".equals(request.getParameter("username"))){
				t_user.setUsername(request.getParameter("username"));
			}
			if(request.getParameter("showname")!=null&&!"".equals(request.getParameter("showname"))){
				t_user.setShowname(request.getParameter("showname"));
			}
			if(request.getParameter("status")!=null&&!"".equals(request.getParameter("status"))){
				t_user.setStatus(request.getParameter("status"));
			}
			if(request.getParameter("address")!=null&&!"".equals(request.getParameter("address"))){
				t_user.setAddress(request.getParameter("address"));
			}
			if(request.getParameter("tel")!=null&&!"".equals(request.getParameter("tel"))){
				t_user.setTel(request.getParameter("tel"));
			}
			if(request.getParameter("phone")!=null&&!"".equals(request.getParameter("phone"))){
				t_user.setPhone(request.getParameter("phone"));
			}
			if(request.getParameter("systemid")!=null&&!"".equals(request.getParameter("systemid"))){
				t_user.setSystemid(request.getParameter("systemid"));
			}
			if(request.getParameter("companyid")!=null&&!"".equals(request.getParameter("companyid"))){
				t_user.setCompanyid(request.getParameter("companyid"));
			}
			if(request.getParameter("branchid")!=null&&!"".equals(request.getParameter("branchid"))){
				t_user.setBranchid(request.getParameter("branchid"));
			}
			if(request.getParameter("deptid")!=null&&!"".equals(request.getParameter("deptid"))){
				t_user.setDeptid(request.getParameter("deptid"));
			}
			if(request.getParameter("termid")!=null&&!"".equals(request.getParameter("termid"))){
				t_user.setTermid(request.getParameter("termid"));
			}
			if(request.getParameter("ismanager")!=null&&!"".equals(request.getParameter("ismanager"))){
				t_user.setIsmanager(request.getParameter("ismanager"));
			}
			if(request.getParameter("issaler")!=null&&!"".equals(request.getParameter("issaler"))){
				t_user.setIssaler(request.getParameter("issaler"));
			}
			if(request.getParameter("createuserid")!=null&&!"".equals(request.getParameter("createuserid"))){
				t_user.setCreateuserid(request.getParameter("createuserid"));
			}
			if(request.getParameter("createtime")!=null&&!"".equals(request.getParameter("createtime"))){
				t_user.setCreatetime(request.getParameter("createtime"));
			}
			if(request.getParameter("lastupdateuserid")!=null&&!"".equals(request.getParameter("lastupdateuserid"))){
				t_user.setLastupdateuserid(request.getParameter("lastupdateuserid"));
			}
			if(request.getParameter("lastupdatetime")!=null&&!"".equals(request.getParameter("lastupdatetime"))){
				t_user.setLastupdatetime(request.getParameter("lastupdatetime"));
			}
			if(request.getParameter("memo")!=null&&!"".equals(request.getParameter("memo"))){
				t_user.setMemo(request.getParameter("memo"));
			}
			if(request.getParameter("ext1")!=null&&!"".equals(request.getParameter("ext1"))){
				t_user.setExt1(request.getParameter("ext1"));
			}
			if(request.getParameter("ext2")!=null&&!"".equals(request.getParameter("ext2"))){
				t_user.setExt2(request.getParameter("ext2"));
			}
			if(request.getParameter("ext3")!=null&&!"".equals(request.getParameter("ext3"))){
				t_user.setExt3(request.getParameter("ext3"));
			}
			if(request.getParameter("joinday")!=null&&!"".equals(request.getParameter("joinday"))){
				t_user.setJoinday(request.getParameter("joinday"));
			}
			if(request.getParameter("personid")!=null&&!"".equals(request.getParameter("personid"))){
				t_user.setPersonid(request.getParameter("personid"));
			}
			if(request.getParameter("sex")!=null&&!"".equals(request.getParameter("sex"))){
				t_user.setSex(request.getParameter("sex"));
			}
			if(request.getParameter("xueli")!=null&&!"".equals(request.getParameter("xueli"))){
				t_user.setXueli(request.getParameter("xueli"));
			}
			if(request.getParameter("zhengshu")!=null&&!"".equals(request.getParameter("zhengshu"))){
				t_user.setZhengshu(request.getParameter("zhengshu"));
			}
			if(request.getParameter("jiguan")!=null&&!"".equals(request.getParameter("jiguan"))){
				t_user.setJiguan(request.getParameter("jiguan"));
			}
			if(request.getParameter("hujidizhi")!=null&&!"".equals(request.getParameter("hujidizhi"))){
				t_user.setHujidizhi(request.getParameter("hujidizhi"));
			}
			if(request.getParameter("hujitype")!=null&&!"".equals(request.getParameter("hujitype"))){
				t_user.setHujitype(request.getParameter("hujitype"));
			}
			if(request.getParameter("marrystatus")!=null&&!"".equals(request.getParameter("marrystatus"))){
				t_user.setMarrystatus(request.getParameter("marrystatus"));
			}
			if(request.getParameter("relationtype")!=null&&!"".equals(request.getParameter("relationtype"))){
				t_user.setRelationtype(request.getParameter("relationtype"));
			}
			if(request.getParameter("contracttype")!=null&&!"".equals(request.getParameter("contracttype"))){
				t_user.setContracttype(request.getParameter("contracttype"));
			}
			if(request.getParameter("contarctstartdate")!=null&&!"".equals(request.getParameter("contarctstartdate"))){
				t_user.setContarctstartdate(request.getParameter("contarctstartdate"));
			}
			if(request.getParameter("contractenddate")!=null&&!"".equals(request.getParameter("contractenddate"))){
				t_user.setContractenddate(request.getParameter("contractenddate"));
			}
			if(request.getParameter("trydate")!=null&&!"".equals(request.getParameter("trydate"))){
				t_user.setTrydate(request.getParameter("trydate"));
			}
			if(request.getParameter("resignstartdate")!=null&&!"".equals(request.getParameter("resignstartdate"))){
				t_user.setResignstartdate(request.getParameter("resignstartdate"));
			}
			if(request.getParameter("resignenddate")!=null&&!"".equals(request.getParameter("resignenddate"))){
				t_user.setResignenddate(request.getParameter("resignenddate"));
			}
			if(request.getParameter("gongjiji")!=null&&!"".equals(request.getParameter("gongjiji"))){
				t_user.setGongjiji(request.getParameter("gongjiji"));
			}
			if(request.getParameter("cardno")!=null&&!"".equals(request.getParameter("cardno"))){
				t_user.setCardno(request.getParameter("cardno"));
			}
			if(request.getParameter("duestartdate")!=null&&!"".equals(request.getParameter("duestartdate"))){
				t_user.setDuestartdate(request.getParameter("duestartdate"));
			}
			if(request.getParameter("ext4")!=null&&!"".equals(request.getParameter("ext4"))){
				t_user.setExt4(request.getParameter("ext4"));
			}
			if(request.getParameter("ext5")!=null&&!"".equals(request.getParameter("ext5"))){
				t_user.setExt5(request.getParameter("ext5"));
			}
			if(request.getParameter("ext6")!=null&&!"".equals(request.getParameter("ext6"))){
				t_user.setExt6(request.getParameter("ext6"));
			}
			if(request.getParameter("ext7")!=null&&!"".equals(request.getParameter("ext7"))){
				t_user.setExt7(request.getParameter("ext7"));
			}
			if(request.getParameter("ext8")!=null&&!"".equals(request.getParameter("ext8"))){
				t_user.setExt8(request.getParameter("ext8"));
			}
			if(request.getParameter("ext9")!=null&&!"".equals(request.getParameter("ext9"))){
				t_user.setExt9(request.getParameter("ext9"));
			}
			if(request.getParameter("ext10")!=null&&!"".equals(request.getParameter("ext10"))){
				t_user.setExt10(request.getParameter("ext10"));
			}
			if(request.getParameter("ext11")!=null&&!"".equals(request.getParameter("ext11"))){
				t_user.setExt11(request.getParameter("ext11"));
			}
			if(request.getParameter("ext12")!=null&&!"".equals(request.getParameter("ext12"))){
				t_user.setExt12(request.getParameter("ext12"));
			}
			if(request.getParameter("quitduedate")!=null&&!"".equals(request.getParameter("quitduedate"))){
				t_user.setQuitduedate(request.getParameter("quitduedate"));
			}
			if(request.getParameter("quitdate")!=null&&!"".equals(request.getParameter("quitdate"))){
				t_user.setQuitdate(request.getParameter("quitdate"));
			}
			if(request.getParameter("workyear")!=null&&!"".equals(request.getParameter("workyear"))){
				t_user.setWorkyear(request.getParameter("workyear"));
			}
			if(request.getParameter("work")!=null&&!"".equals(request.getParameter("work"))){
				t_user.setWork(request.getParameter("work"));
			}
			if(request.getParameter("borndate")!=null&&!"".equals(request.getParameter("borndate"))){
				t_user.setBorndate(request.getParameter("borndate"));
			}
			if(request.getParameter("jobstatus")!=null&&!"".equals(request.getParameter("jobstatus"))){
				t_user.setJobstatus(request.getParameter("jobstatus"));
			}
      	    if(request.getParameter("id")!=null&&!"".equals(request.getParameter("id"))){
	        	t_user.setId(new Integer(request.getParameter("id")));
	        }

	        if(request.getParameter("startdate")!=null&&!"".equals(request.getParameter("startdate"))){
	        	t_user.setStartdate(request.getParameter("startdate"));
	        }
	        if(request.getParameter("enddate")!=null&&!"".equals(request.getParameter("enddate"))){
	        	t_user.setEnddate(request.getParameter("enddate"));
	        }
	        t_user.setStartNo( startIndex );
	        t_user.setEndNo( pageSize );
	    	List<T_user> findAll = service.findAll(t_user);
	        int totalCount = service.findCountAll(t_user);
	       	pg = new Pg(findAll, totalCount, pageSize, startIndex);
	       	request.setAttribute("t_userList", findAll);
		    request.setAttribute("pg", pg);
	    } catch (Exception e) {
			e.printStackTrace();
			log.error("------query t_userList error:"+e);
		}

		return pg;
	}

	/**
	 * 2、新增保存  T_user信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_user
	 * @param request
	 * @return
	 */
	@RequestMapping("/saveT_user")
	@ResponseBody
	public JsonVO saveT_user(T_user t_user, HttpServletRequest request,HttpServletResponse response){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		//如果有特殊需求，需要将json对象值转成java实体对象属性值
		t_user.setCreatetime(DateUtil.getCurrDateTimeStand());
		t_user.setCreateuserid(request.getSession().getAttribute("FREE_CURRENT_USER").toString());

		if(service.save(t_user)>0){
	        vo.setResult("success");
	        vo.setJieguo(true);
		}
		return vo;
	}

	@RequestMapping("/updateT_userDangan")
	@ResponseBody
	public JsonVO updateT_userDangan(T_user t_user, HttpServletRequest request){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		String jixiao = t_user.getResult();
		//如果有特殊值需要处理，在此处手工转换
		T_user t_userTemp = service.findById(t_user);
		t_userTemp.setJoinday(t_user.getJoinday());
		//minzu   xuexing  shengao  tizhong  health
		t_userTemp.setMinzu(t_user.getMinzu());
		t_userTemp.setXuexing(t_user.getXuexing());
		t_userTemp.setShengao(t_user.getShengao());
		t_userTemp.setTizhong(t_user.getTizhong());
		t_userTemp.setHealth(t_user.getHealth());
		//zhengzhimianmao  importlinkname  importrel  linkaddress  qq
		t_userTemp.setZhengzhimianmao(t_user.getZhengzhimianmao());
		t_userTemp.setImportlinkname(t_user.getImportlinkname());
		t_userTemp.setImportrel(t_user.getImportrel());
		t_userTemp.setLinkaddress(t_user.getLinkaddress());
		t_userTemp.setQq(t_user.getQq());
		//signdate
		t_userTemp.setSigndate(t_user.getSigndate());

		// home1  homename1  zhengzhimianmao1 homeborndate1  homewenhua1  homeworker1  homelink1
		t_userTemp.setHome1(t_user.getHome1());
		t_userTemp.setHomename1(t_user.getHomename1());
		t_userTemp.setZhengzhimianmao1(t_user.getZhengzhimianmao1());
		t_userTemp.setHomeborndate1(t_user.getHomeborndate1());
		t_userTemp.setHomewenhua1(t_user.getHomewenhua1());
		t_userTemp.setHomeworker1(t_user.getHomeworker1());
		t_userTemp.setHomelink1(t_user.getHomelink1());

		t_userTemp.setHome2(t_user.getHome2());
		t_userTemp.setHomename2(t_user.getHomename2());
		t_userTemp.setZhengzhimianmao2(t_user.getZhengzhimianmao2());
		t_userTemp.setHomeborndate2(t_user.getHomeborndate2());
		t_userTemp.setHomewenhua2(t_user.getHomewenhua2());
		t_userTemp.setHomeworker2(t_user.getHomeworker2());
		t_userTemp.setHomelink2(t_user.getHomelink2());

		t_userTemp.setHome3(t_user.getHome3());
		t_userTemp.setHomename3(t_user.getHomename3());
		t_userTemp.setZhengzhimianmao3(t_user.getZhengzhimianmao3());
		t_userTemp.setHomeborndate3(t_user.getHomeborndate3());
		t_userTemp.setHomewenhua3(t_user.getHomewenhua3());
		t_userTemp.setHomeworker3(t_user.getHomeworker3());
		t_userTemp.setHomelink3(t_user.getHomelink3());

		t_userTemp.setLastupdatetime(DateUtil.getCurrDateTimeStand());
		t_userTemp.setLastupdateuserid(request.getSession().getAttribute("FREE_CURRENT_USER").toString());

		if(service.update(t_userTemp)>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}
		return vo;
	}

	@RequestMapping("/updateT_userJixiao")
	@ResponseBody
	public JsonVO updateT_userJixiao(T_user t_user, HttpServletRequest request){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		String jixiao = t_user.getResult();
		//如果有特殊值需要处理，在此处手工转换
		T_user t_userTemp = service.findById(t_user);
		if(t_user.getMonth().equals("1")){
			t_userTemp.setMonth1(jixiao);
		}else if(t_user.getMonth().equals("2")){
			t_userTemp.setMonth2(jixiao);
		}else if(t_user.getMonth().equals("3")){
			t_userTemp.setMonth3(jixiao);
		}else if(t_user.getMonth().equals("4")){
			t_userTemp.setMonth4(jixiao);
		}else if(t_user.getMonth().equals("5")){
			t_userTemp.setMonth5(jixiao);
		}else if(t_user.getMonth().equals("6")){
			t_userTemp.setMonth6(jixiao);
		}else if(t_user.getMonth().equals("7")){
			t_userTemp.setMonth7(jixiao);
		}else if(t_user.getMonth().equals("8")){
			t_userTemp.setMonth8(jixiao);
		}else if(t_user.getMonth().equals("9")){
			t_userTemp.setMonth9(jixiao);
		}else if(t_user.getMonth().equals("10")){
			t_userTemp.setMonth10(jixiao);
		}else if(t_user.getMonth().equals("11")){
			t_userTemp.setMonth11(jixiao);
		}else if(t_user.getMonth().equals("12")){
			t_userTemp.setMonth12(jixiao);
		}
		t_userTemp.setLastupdatetime(DateUtil.getCurrDateTimeStand());
		t_userTemp.setLastupdateuserid(request.getSession().getAttribute("FREE_CURRENT_USER").toString());

		if(service.update(t_userTemp)>0){
			vo.setResult("success");
			vo.setJieguo(true);
		}
		return vo;
	}

	/**
	 * 3、修改T_user信息并且返回成功或者失败信息json格式结果如：result:[success/error]
	 * @param t_user
	 * @param request
	 * @return JsonVO
	 */
	@RequestMapping("/updateT_user")
	@ResponseBody
	public JsonVO updateT_user(T_user t_user, HttpServletRequest request){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		//如果有特殊值需要处理，在此处手工转换
		//T_user t_userTemp = service.findById(t_user);
		//t_userTemp.setXXX(t_user.getXXX());
		//if(service.update(t_userTemp)){
		t_user.setLastupdatetime(DateUtil.getCurrDateTimeStand());
		t_user.setLastupdateuserid(request.getSession().getAttribute("FREE_CURRENT_USER").toString());

		if(service.update(t_user)>0){
	        vo.setResult("success");
	        vo.setJieguo(true);

		}
		return vo;
	}

	/**
	 * 4、根据id查询T_user单个信息并显示在修改页面
	 * @param id
	 * @param request
	 * @return T_user json格式字符串
	 */
	@RequestMapping("/getT_user")
	@ResponseBody
	public T_user getT_user(Integer id,HttpServletRequest request){
		T_user t_user = new T_user();
		t_user.setId(id);
		return service.findById(t_user);
	}

	/**
	 * 5、删除T_user根据id
	 * @param id
	 * @param request
	 * @param response
	 * return JsonVO ：json格式字符串
	 */
	@RequestMapping("/delT_user")
	@ResponseBody
	public JsonVO delT_user(Integer id,HttpServletRequest request,HttpServletResponse response){
        JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);

		T_user t_user = new T_user();
		t_user.setId(id);
		t_user = service.findById(t_user);

		if(service.delete(t_user)>0){
			//删除该用户对应 role 数据；
			T_user_role t_user_role = new T_user_role();
			t_user_role.setUserid(t_user.getUserid());
			t_user_role.setStartNo(0);
			t_user_role.setEndNo(1000);
			t_user_role.setPageSize(1000);
			List userRoleList= t_user_roleService.findAll(t_user_role);
			if(userRoleList !=null && userRoleList.size()>0){
				Iterator it = userRoleList.iterator();
				while(it.hasNext()){
					T_user_role  tempuserrole = (T_user_role)it.next();
					t_user_roleService.delete(tempuserrole);
				}
			}

			//删除该用户对应 function 数据；
			T_user_function t_user_function = new T_user_function();
			t_user_function.setUserid(t_user.getUserid());
			t_user_function.setStartNo(0);
			t_user_function.setEndNo(1000);
			t_user_function.setPageSize(1000);
			List userFunctionList= t_user_functionService.findAll(t_user_function);
			if(userFunctionList !=null && userFunctionList.size()>0){
				Iterator it = userFunctionList.iterator();
				while(it.hasNext()){
					T_user_function  tempuserfunction = (T_user_function)it.next();
					t_user_functionService.delete(tempuserfunction);
				}
			}

			vo.setResult("success");
	        vo.setJieguo(true);
		}
		return vo;
	}

	/**
	 * 6、跳转到t_user/toT_userList查询所有数据页面
	 *  return /WEB-INF/views/auth/t_user/t_userList.jsp
	 */
	@RequestMapping(value = "/toT_userList")
	public String toT_userList() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userList.jsp------");
		return "auth/t_user/t_userList";
	}
	@RequestMapping(value = "/toT_userListManager")
	public String toT_userListManager() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userListManager.jsp------");
		return "auth/t_user/t_userListManager";
	}
	@RequestMapping(value = "/toT_userCurdManager")
	public String toT_userCurdManager() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userCurdManager.jsp------");
		return "auth/t_user/t_userCurdManager";
	}

	@RequestMapping(value = "/toT_userCurdDangan")
	public String toT_userCurdDangan() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userCurdDangan.jsp------");
		return "auth/t_user/t_userCurdDangan";
	}

	/**
	 * 7、新增、修改、详情页面t_user/toT_userCurd跳转
     * auth/t_user/T_userCurd.jsp
	 */
    @RequestMapping(value = "/toT_userCurd")
    public String toT_userCurd() {
    	log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userCurd.jsp------");
        return "auth/t_user/t_userCurd";
    }

	/**
	 * 跳转到t_user/toT_userList查询所有数据页面
	 *  return /WEB-INF/views/auth/t_user/t_userList.jsp
	 */
	@RequestMapping(value = "/toT_userListTongxunlu")
	public String toT_userListTongxunlu() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userListTongxunlu.jsp------");
		return "auth/t_user/t_userListTongxunlu";
	}

	@RequestMapping(value = "/toT_userListJixiao")
	public String toT_userListJixiao() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userListJixiao.jsp------");
		return "auth/t_user/t_userListJixiao";
	}
	@RequestMapping(value = "/toT_userCurdJixiao")
	public String toT_userCurdJixiao() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userCurdJixiao.jsp------");
		return "auth/t_user/t_userCurdJixiao";
	}

	/**
	 * 新增、修改、详情页面t_user/toT_userCurd跳转
	 * auth/t_user/T_userCurd.jsp
	 */
	@RequestMapping(value = "/toT_userCurdTongxunlu")
	public String toT_userCurdTongxunlu() {
		log.debug("------跳转到/WEB-INF/views/auth/t_user/t_userCurdTongxunlu.jsp------");
		return "auth/t_user/t_userCurdTongxunlu";
	}

    /**
	 * 8、批量删除T_user根据主键id
	 * 是否要实现批量删除，待考虑，基本上用途不大
	 * @param id
	 * @param request
	 * @param response
	@RequestMapping("/delT_userBatch")
	public String delT_userBatch(HttpServletRequest request,HttpServletResponse response){
		String[] ids = request.getParameterValues("ids");
		System.out.println("------ids="+ids);
		T_user t_user = new T_user();
		int j=0;
		for(int i =0;i< ids.length;i++){
			j++;
			log.error("------ids[i]="+ids[i]);
			t_user.setId(new Integer(ids[i]).intValue());
			service.delete(t_user);
		}
		if(j==ids.length){
			log.debug("------t_user批量删除成功！------");
		}else{
			log.error("------t_user批量删除部分成功！部分失败！------");
		}

		return "redirect:/t_user/getAllT_user";
	}
*/

    /**
	 * 9、首页密码修改页面
	 * @param t_user
	 * @param request
	 * @return JsonVO
	 */
	@RequestMapping("/updateP_userP")
	@ResponseBody
	public JsonVO updateP_userP(T_user t_user, HttpServletRequest request){
		JsonVO vo = new JsonVO();
		vo.setResult("error");
		vo.setJieguo(false);
		String oldpassword=request.getParameter("oldpassword");
		String newpassword=request.getParameter("newpassword");
		String renewpassword=request.getParameter("renewpassword");
		T_user user = (T_user)request.getSession().getAttribute("FREE_CURRENT_USER_OBJ");
		if(oldpassword.equals(user.getPassword())&&newpassword.equals(renewpassword)){
			System.out.println("user="+user);
			T_user tuser_new = service.findById(user);
			tuser_new.setPassword(newpassword);
			if(service.update(tuser_new)>0){
		        vo.setResult("success");
		        vo.setJieguo(true);
			}
		}
		return vo;
	}
}